# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=filezilla
pkgver=3.66.5
pkgrel=1
pkgdesc="FTP Client"
url="https://filezilla-project.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	autoconf
	automake
	boost-dev
	gnutls-dev
	gtk+3.0-dev
	libfilezilla-dev
	libidn-dev
	libtool
	pugixml-dev
	sqlite-dev
	wxwidgets-dev
	xdg-utils
	"
subpackages="$pkgname-doc $pkgname-lang"
source="https://download.filezilla-project.org/client/FileZilla_${pkgver}_src.tar.xz"

case "$CARCH" in
s390x) options="$options !check";; # ratelimit_test fails
esac

# secfixes:
#   3.66.4-r0:
#     - CVE-2023-48795

prepare() {
	default_prepare

	# patched autoconf
	NOCONFIGURE=1 autoreconf -vif
}

build() {
	case "$CARCH" in
	x86)
		# fails to build otherwise
		export CFLAGS="$CFLAGS -D_FORCE_SOFTWARE_SHA"
		;;
	esac
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--without-dbus \
		--disable-manualupdatecheck \
		--disable-autoupdatecheck
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
b250e65894a3e8c8eb0eac25b3ffa5cd1348df2a38b1e6fa5eb735fff1945dbeb1fbcfe10a8188c260e9fbeaeb78322cb8aa56f6386fd39803421d01bbc8b2dd  FileZilla_3.66.5_src.tar.xz
"
